package com.stropheware.droidDefense;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout.LayoutParams;

public class AnimationExample extends Activity{ 
    
	@Override
	public void onCreate(Bundle icicle) { 
        super.onCreate(icicle); 
        LinearLayout linLayout = new LinearLayout(this); 
        linLayout.setBackgroundResource(R.color.white);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        // load the origial BitMap (500 x 500 px) 
        Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), 
               R.drawable.prelim_tower); 
        
        // make a Drawable from Bitmap to allow to set the BitMap 
        // to the ImageView, ImageButton or what ever 
        BitmapDrawable bmd = new BitmapDrawable(bitmapOrg); 
        
        ImageView imageView = new ImageView(this); 
        
        // set the Drawable on the ImageView 
        imageView.setImageDrawable(bmd); 
      
        // center the Image 
        imageView.setScaleType(ScaleType.CENTER); 
        
        // add ImageView to the Layout 
        linLayout.addView(imageView, 
          new LinearLayout.LayoutParams( 
                      LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT
                ) 
        ); 
        
        // set LinearLayout as ContentView 
        setContentView(linLayout);
        animate(imageView);
    } 

	private void animate(ImageView view){
		Animation rotate = AnimationUtils.loadAnimation(this, R.anim.rotate);
		view.startAnimation(rotate);
	}
	
}